# kinds                                                               -*- sh -*-
#
# For documentation on this file format, please refer to
# src/theory/builtin/kinds.
#

theory THEORY_SETS \
    ::cvc5::internal::theory::sets::TheorySets \
    "theory/sets/theory_sets.h"
typechecker "theory/sets/theory_sets_type_rules.h"
rewriter ::cvc5::internal::theory::sets::TheorySetsRewriter \
    "theory/sets/theory_sets_rewriter.h"

properties parametric
properties check presolve

# constants
constant SET_EMPTY\
  class \
  EmptySet \
  ::cvc5::internal::EmptySetHashFunction \
  "expr/emptyset.h" \
  "the empty set constant; payload is an instance of the cvc5::internal::EmptySet class"

# the type
operator SET_TYPE 1 "set type, takes as parameter the type of the elements"
cardinality SET_TYPE \
    "::cvc5::internal::theory::sets::SetsProperties::computeCardinality(%TYPE%)" \
    "theory/sets/theory_sets_type_rules.h"
well-founded SET_TYPE \
    "::cvc5::internal::theory::sets::SetsProperties::isWellFounded(%TYPE%)" \
    "::cvc5::internal::theory::sets::SetsProperties::mkGroundTerm(%TYPE%)" \
    "theory/sets/theory_sets_type_rules.h"
enumerator SET_TYPE \
    "::cvc5::internal::theory::sets::SetEnumerator" \
    "theory/sets/theory_sets_type_enumerator.h"

# operators
operator SET_UNION          2  "set union"
operator SET_INTER   2  "set intersection"
operator SET_MINUS          2  "set subtraction"
operator SET_SUBSET         2  "subset predicate; first parameter a subset of second"
operator SET_MEMBER         2  "set membership predicate; first parameter a member of second"

operator SET_SINGLETON 1 "constructs a set of a single element. First parameter is a term"

operator SET_INSERT         2: "set obtained by inserting elements (first N-1 parameters) into a set (the last parameter)"
operator SET_CARD           1  "set cardinality operator"
operator SET_COMPLEMENT     1  "set complement (with respect to finite universe)"
nullaryoperator SET_UNIVERSE "(finite) universe set, all set variables must be interpreted as subsets of it."

# A set comprehension is specified by:
# (1) a bound variable list x1 ... xn,
# (2) a predicate P[x1...xn], and
# (3) a term t[x1...xn].
# A comprehension C with the above form has members given by the following
# semantics:
# forall y. ( exists x1...xn. P[x1...xn] ^ t[x1...xn] = y ) <=> (member y C)
# where y ranges over the element type of the (set) type of the comprehension.
# Notice that since all sets must be interpreted as finite, this means that
# cvc5 will not be able to construct a model for any set comprehension such
# that there are infinitely many y that satisfy the left hand side of the
# equivalence above. The same limitation occurs more generally when combining
# finite sets with quantified formulas.
operator SET_COMPREHENSION 3 "set comprehension specified by a bound variable list, a predicate, and a term."

# The operator choose returns an element from a given set.
# If set A = {x}, then the term (choose A) is equivalent to the term x.
# If the set is empty, then (choose A) is an arbitrary value.
# If the set has cardinality > 1, then (choose A) will deterministically return an element in A.
operator SET_CHOOSE        1  "return an element in the set given as a parameter"

# The operator is_singleton returns whether the given set is a singleton
operator SET_IS_SINGLETON  1  "return whether the given set is a singleton"

# The set.map operator applies the first argument, a function of type (-> T1 T2), to every element
# of the second argument, a set of type (Set T1), and returns a set of type (Set T2).
operator SET_MAP           2  "set map function"

# The set.filter operator takes a predicate of type (-> T Bool) and a set of type (Set T)
# and returns the same set excluding those elements that do not satisfy the predicate
operator SET_FILTER        2  "set filter operator"

# set.fold operator combines elements of a set into a single value.
# (set.fold f t A) folds the elements of bag A starting with term t and using
# the combining function f.
#  f: a binary operation of type (-> T1 T2 T2)
#  t: an initial value of type T2
#  A: a bag of type (Set T1)
operator SET_FOLD          3  "set fold operator"

# rel.group operator
constant RELATION_GROUP_OP \
  class \
  ProjectOp+ \
  ::cvc5::internal::ProjectOpHashFunction \
  "theory/datatypes/project_op.h" \
  "operator for RELATION_GROUP; payload is an instance of the cvc5::internal::ProjectOp class"

parameterized RELATION_GROUP RELATION_GROUP_OP 1 "relation group"

# relation aggregate operator
constant RELATION_AGGREGATE_OP \
  class \
  ProjectOp+ \
  ::cvc5::internal::ProjectOpHashFunction \
  "theory/datatypes/project_op.h" \
  "operator for RELATION_AGGREGATE; payload is an instance of the cvc5::internal::ProjectOp class"

parameterized RELATION_AGGREGATE RELATION_AGGREGATE_OP 3 "relation aggregate"

# rel.project operator extends datatypes tuple_project operator to a set of tuples
constant RELATION_PROJECT_OP \
  class \
  ProjectOp+ \
  ::cvc5::internal::ProjectOpHashFunction \
  "theory/datatypes/project_op.h" \
  "operator for RELATION_PROJECT; payload is an instance of the cvc5::internal::ProjectOp class"

parameterized RELATION_PROJECT RELATION_PROJECT_OP 1 "relation projection"

operator RELATION_JOIN 		   2  "relation join"
operator RELATION_PRODUCT 	   2  "relation cartesian product"
operator RELATION_TRANSPOSE    1  "relation transpose"
operator RELATION_TCLOSURE     1  "relation transitive closure"
operator RELATION_JOIN_IMAGE   2  "relation join image"
operator RELATION_IDEN 	   	   1  "relation identity"

typerule SET_UNION          ::cvc5::internal::theory::sets::SetsBinaryOperatorTypeRule
typerule SET_INTER   ::cvc5::internal::theory::sets::SetsBinaryOperatorTypeRule
typerule SET_MINUS          ::cvc5::internal::theory::sets::SetsBinaryOperatorTypeRule
typerule SET_SUBSET         ::cvc5::internal::theory::sets::SubsetTypeRule
typerule SET_MEMBER         ::cvc5::internal::theory::sets::MemberTypeRule
typerule SET_SINGLETON      ::cvc5::internal::theory::sets::SingletonTypeRule
typerule SET_EMPTY          ::cvc5::internal::theory::sets::EmptySetTypeRule
typerule SET_INSERT         ::cvc5::internal::theory::sets::InsertTypeRule
typerule SET_CARD           ::cvc5::internal::theory::sets::CardTypeRule
typerule SET_COMPLEMENT     ::cvc5::internal::theory::sets::ComplementTypeRule
typerule SET_UNIVERSE       ::cvc5::internal::theory::sets::UniverseSetTypeRule
typerule SET_COMPREHENSION  ::cvc5::internal::theory::sets::ComprehensionTypeRule
typerule SET_CHOOSE         ::cvc5::internal::theory::sets::ChooseTypeRule
typerule SET_IS_SINGLETON   ::cvc5::internal::theory::sets::IsSingletonTypeRule
typerule SET_MAP            ::cvc5::internal::theory::sets::SetMapTypeRule
typerule SET_FILTER         ::cvc5::internal::theory::sets::SetFilterTypeRule
typerule SET_FOLD           ::cvc5::internal::theory::sets::SetFoldTypeRule

typerule RELATION_JOIN 			::cvc5::internal::theory::sets::RelBinaryOperatorTypeRule
typerule RELATION_PRODUCT 		::cvc5::internal::theory::sets::RelBinaryOperatorTypeRule
typerule RELATION_TRANSPOSE 	::cvc5::internal::theory::sets::RelTransposeTypeRule
typerule RELATION_TCLOSURE 	    ::cvc5::internal::theory::sets::RelTransClosureTypeRule
typerule RELATION_JOIN_IMAGE	::cvc5::internal::theory::sets::JoinImageTypeRule
typerule RELATION_IDEN 			::cvc5::internal::theory::sets::RelIdenTypeRule
typerule RELATION_GROUP_OP      "SimpleTypeRule<RBuiltinOperator>"
typerule RELATION_GROUP         ::cvc5::internal::theory::sets::RelationGroupTypeRule
typerule RELATION_AGGREGATE_OP  "SimpleTypeRule<RBuiltinOperator>"
typerule RELATION_AGGREGATE     ::cvc5::internal::theory::sets::RelationAggregateTypeRule
typerule RELATION_PROJECT_OP    "SimpleTypeRule<RBuiltinOperator>"
typerule RELATION_PROJECT       ::cvc5::internal::theory::sets::RelationProjectTypeRule

construle SET_UNION         ::cvc5::internal::theory::sets::SetsBinaryOperatorTypeRule
construle SET_SINGLETON     ::cvc5::internal::theory::sets::SingletonTypeRule

endtheory
